package com.muyu.cart.constant;

import lombok.Getter;

/**
 * 商品状态枚举
 *
 * @author JiaCheng
 * @version 1.0
 * @description: 商品状态枚举
 * @date 2025-09-21
 */
@Getter
public enum ProductStatusEnum {

    /**
     * 下架
     */
    OFFLINE(0, "下架"),

    /**
     * 上架
     */
    ONLINE(1, "上架");

    private final Integer code;
    private final String info;

    ProductStatusEnum(Integer code, String info) {
        this.code = code;
        this.info = info;
    }

    /**
     * 根据状态码获取枚举
     */
    public static ProductStatusEnum getByCode(Integer code) {
        for (ProductStatusEnum status : values()) {
            if (status.getCode().equals(code)) {
                return status;
            }
        }
        return OFFLINE;
    }
}
